<template>
    <div>
        <el-form>
            <el-form-item>
                <el-input v-model="changeText"></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="text"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button @click="clearText">清空</el-button>
                <el-button @click="$emit('addText', text)">添加</el-button>
                <el-button @click="$emit('resetText')">重置</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
import { ref, onMounted } from "vue";
import bus from "vue3-eventbus"
export default {
    name: "ToDo",
    props: {
        // fuxiangzi传值
        // msg: String,
    },
    setup() {
        const text = ref("")
        const clearText = function () {
            text.value = ""
        }
        const changeText=ref()
        onMounted(() => {
            bus.on('getMsg', (value) => {
                changeText.value=value
            })
        })
        // const addText = function () {
        //     console.log(text.value);
        // }
        // const resetText = function () {

        // }
        // 
        // const submit=function(){
        //     cxt.emit('toList',text.value)
        //     text.value=""
        // }
        return {
            text,
            clearText,
            changeText
            // addText,
            // resetText,
        }
    }
}
</script>
<style></style>